<template>
  <div class="subject">
    <div v-for="(item, index) in list" :key="index">
      <span>{{ item.first }}</span>
      <span>+</span>
      <span>{{ item.last }}</span>
      <span>=</span>
      <input type="number" v-model.number="item.key" />
      <button @click="submit(index)">提交</button>
    </div>

  </div>
</template>

<script>
import Bus from '@/utils/Bus';

export default {
  props: {
    list: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
    }
  },
  methods: {
    submit(index) {
      Bus.$emit('submit', this.list[index].answer, this.list[index].key)
    }
  }
};
</script>

<style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}

.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}

.subject input {
  width: 50px;
  height: 20px;
}
</style>